using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.fight
{
[System.Serializable]
public  class Attr :   cfg.EditorReadWriter 
 {

    public float hpfull ;
     public float mpfull ;
     public float attack ;
     public float defence ;
     public float lucky ;
     public float critical ;
     public float avoidance ;
     public float speed ;
     


    public const int TYPE_ID = 1905959161;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(8);
        os.WriteSize(Tag.FLOAT | (1 << Tag.TAG_SHIFT));  os.WriteFloat(hpfull);  
         os.WriteSize(Tag.FLOAT | (2 << Tag.TAG_SHIFT));  os.WriteFloat(mpfull);  
         os.WriteSize(Tag.FLOAT | (3 << Tag.TAG_SHIFT));  os.WriteFloat(attack);  
         os.WriteSize(Tag.FLOAT | (4 << Tag.TAG_SHIFT));  os.WriteFloat(defence);  
         os.WriteSize(Tag.FLOAT | (5 << Tag.TAG_SHIFT));  os.WriteFloat(lucky);  
         os.WriteSize(Tag.FLOAT | (6 << Tag.TAG_SHIFT));  os.WriteFloat(critical);  
         os.WriteSize(Tag.FLOAT | (7 << Tag.TAG_SHIFT));  os.WriteFloat(avoidance);  
         os.WriteSize(Tag.FLOAT | (8 << Tag.TAG_SHIFT));  os.WriteFloat(speed);  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.FLOAT | (1 << Tag.TAG_SHIFT)):   hpfull = os.ReadFloat(); break;  
             case (Tag.FLOAT | (2 << Tag.TAG_SHIFT)):   mpfull = os.ReadFloat(); break;  
             case (Tag.FLOAT | (3 << Tag.TAG_SHIFT)):   attack = os.ReadFloat(); break;  
             case (Tag.FLOAT | (4 << Tag.TAG_SHIFT)):   defence = os.ReadFloat(); break;  
             case (Tag.FLOAT | (5 << Tag.TAG_SHIFT)):   lucky = os.ReadFloat(); break;  
             case (Tag.FLOAT | (6 << Tag.TAG_SHIFT)):   critical = os.ReadFloat(); break;  
             case (Tag.FLOAT | (7 << Tag.TAG_SHIFT)):   avoidance = os.ReadFloat(); break;  
             case (Tag.FLOAT | (8 << Tag.TAG_SHIFT)):   speed = os.ReadFloat(); break;  
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "Attr");
        ele.WriteStartElement("hpfull"); ele.WriteAttributeString("id", "1"); ele.WriteFloat(hpfull); ele.WriteEndElement();
         ele.WriteStartElement("mpfull"); ele.WriteAttributeString("id", "2"); ele.WriteFloat(mpfull); ele.WriteEndElement();
         ele.WriteStartElement("attack"); ele.WriteAttributeString("id", "3"); ele.WriteFloat(attack); ele.WriteEndElement();
         ele.WriteStartElement("defence"); ele.WriteAttributeString("id", "4"); ele.WriteFloat(defence); ele.WriteEndElement();
         ele.WriteStartElement("lucky"); ele.WriteAttributeString("id", "5"); ele.WriteFloat(lucky); ele.WriteEndElement();
         ele.WriteStartElement("critical"); ele.WriteAttributeString("id", "6"); ele.WriteFloat(critical); ele.WriteEndElement();
         ele.WriteStartElement("avoidance"); ele.WriteAttributeString("id", "7"); ele.WriteFloat(avoidance); ele.WriteEndElement();
         ele.WriteStartElement("speed"); ele.WriteAttributeString("id", "8"); ele.WriteFloat(speed); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  hpfull = ele.ReadFloat(); break; 
                 case 2:  mpfull = ele.ReadFloat(); break; 
                 case 3:  attack = ele.ReadFloat(); break; 
                 case 4:  defence = ele.ReadFloat(); break; 
                 case 5:  lucky = ele.ReadFloat(); break; 
                 case 6:  critical = ele.ReadFloat(); break; 
                 case 7:  avoidance = ele.ReadFloat(); break; 
                 case 8:  speed = ele.ReadFloat(); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "hpfull":  hpfull = ele.ReadFloat(); break; 
                 case "mpfull":  mpfull = ele.ReadFloat(); break; 
                 case "attack":  attack = ele.ReadFloat(); break; 
                 case "defence":  defence = ele.ReadFloat(); break; 
                 case "lucky":  lucky = ele.ReadFloat(); break; 
                 case "critical":  critical = ele.ReadFloat(); break; 
                 case "avoidance":  avoidance = ele.ReadFloat(); break; 
                 case "speed":  speed = ele.ReadFloat(); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
